﻿using System;
using System.Net.Http;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac.WebAssembly;




using AntDesign.ProLayout;
using Volo.Abp.Features;
using Volo.Abp.Modularity;
using Volo.Abp.AutoMapper;
using ERP.Workflow.Designer.HttpApi.Client;
using ERP.Workflow.Designer.BlazorUI.Menus;
using Volo.Abp.UI.Navigation;
using ERP.Abp.AspnetCore.Components.Web.AntDesignTheme.Routing;

namespace ERP.Workflow.Designer.BlazorUI;
[DependsOn(
    typeof(AbpAutofacWebAssemblyModule),
    typeof(WorkflowDesignerHttpApiClientModule),
    typeof(AbpAutoMapperModule)

)]
public class WorkflowDesignerBlazorUIModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        //context.Services.AddAutoMapperObjectMapper<WorkflowDesignerBlazorUIModule>();
        var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
        var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();

        ConfigureAutoMapper(context);
        ConfigureMenu(context);
        ConfigureRouter(context);
    }
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
        base.PreConfigureServices(context);
    }
    private void ConfigureAutoMapper(ServiceConfigurationContext context)
    {
        Configure<AbpAutoMapperOptions>(options =>
        {
            options.AddProfile<WorkflowDesignerBlazorUIAutoMapperProfile>();
        });
    }
    private void ConfigureMenu(ServiceConfigurationContext context)
    {
        Configure<AbpNavigationOptions>(options =>
        {
            options.MenuContributors.Add(new WorkflowDesignerMenuContributor(context.Services.GetConfiguration()));
        });
    }
    private void ConfigureRouter(ServiceConfigurationContext context)
    {
        Configure<AbpRouterOptions>(options =>
        {
            options.AdditionalAssemblies.Add(typeof(WorkflowDesignerBlazorUIModule).Assembly);
        });
    }
}
